﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Castle.MicroKernel.Registration;
using Data.Mappers;
using Shop.Mappers;

namespace Shop.Installers
{
    public class MappersInstaller : IWindsorInstaller
    {
        public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
        {
            container.Register(Classes.FromThisAssembly()
                    .Where(Component.IsInSameNamespaceAs<WebMapper>())
                    .WithService.DefaultInterfaces()
                    .LifestylePerWebRequest());

            container.Register(Classes.FromAssemblyNamed("Data")
                    .Where(Component.IsInSameNamespaceAs<ProductMapper>())
                    .WithService.AllInterfaces()
                    .LifestylePerWebRequest());

            container.Register(Classes.FromAssemblyNamed("Data")
                    .Where(Component.IsInSameNamespaceAs<BasketMapper>())
                    .WithService.AllInterfaces()
                    .LifestylePerWebRequest());

            container.Register(Classes.FromAssemblyNamed("Data")
                    .Where(Component.IsInSameNamespaceAs<CategoryMapper>())
                    .WithService.AllInterfaces()
                    .LifestylePerWebRequest());

            container.Register(Classes.FromAssemblyNamed("Data")
                    .Where(Component.IsInSameNamespaceAs<OrderPositionMapper>())
                    .WithService.AllInterfaces()
                    .LifestylePerWebRequest());

            container.Register(Classes.FromAssemblyNamed("Data")
                    .Where(Component.IsInSameNamespaceAs<RoleMapper>())
                    .WithService.AllInterfaces()
                    .LifestylePerWebRequest());

            container.Register(Classes.FromAssemblyNamed("Data")
                    .Where(Component.IsInSameNamespaceAs<UserMapper>())
                    .WithService.AllInterfaces()
                    .LifestylePerWebRequest());
            
        }
    }
}